package com.xbongbong.pro.enums.cloudcode.enums;

import com.xbongbong.pro.enums.permission.enums.ProPermissionAliasEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * 云叩控件
 * 创建时间 2020/9/21 2:48 PM
 * 修改时间 2020/9/21 2:48 PM
 * @author chy
 */
@Getter
public enum CloudCodeAppPermissinlEnum {

    /**
     * 云叩控件枚举类
     */
    CRM(XbbRefTypeEnum.CRM.getCode(), ProPermissionAliasEnum.CRM),
    CUSTOMER_MANAGEMENT(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), ProPermissionAliasEnum.CUSTOMER_MANAGEMENT),
    CONTACT(XbbRefTypeEnum.CONTACT.getCode(), ProPermissionAliasEnum.CONTACT),
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), ProPermissionAliasEnum.CUSTOMER_COMMUNICATE),
    COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), ProPermissionAliasEnum.COMMUNICATE_PLAN),
    SALES_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), ProPermissionAliasEnum.SALES_OPPORTUNITY),
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(), ProPermissionAliasEnum.CONTRACT),
    SIGN_IN(XbbRefTypeEnum.SIGNIN.getCode(), ProPermissionAliasEnum.SIGN_IN),
    WORK_REPORT(XbbRefTypeEnum.WORK_REPORT.getCode(), ProPermissionAliasEnum.WORK_REPORT),
    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), ProPermissionAliasEnum.QUOTATION),
    REFUND(XbbRefTypeEnum.REFUND.getCode(), ProPermissionAliasEnum.REFUND),

    JXC(XbbRefTypeEnum.JXC.getCode(), ProPermissionAliasEnum.JXC),
    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(), ProPermissionAliasEnum.SUPPLIER),
    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), ProPermissionAliasEnum.SUPPLIER_CONTACT),
    SUPPLIER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), ProPermissionAliasEnum.SUPPLIER_COMMUNICATE),
    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(), ProPermissionAliasEnum.PURCHASE),
    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE),
    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(), ProPermissionAliasEnum.ASSEMBLE),
    INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(), ProPermissionAliasEnum.INSTOCK),
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), ProPermissionAliasEnum.PURCHASE_INSTOCK),
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), ProPermissionAliasEnum.REFUND_INSTOCK),
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_INSTOCK),
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK),
    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK),
    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK),
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK),


    WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK),
    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(), ProPermissionAliasEnum.OUTSTOCK),
    INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(), ProPermissionAliasEnum.INVENTORY),
    TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(), ProPermissionAliasEnum.TRANSFER),
    WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getCode(), ProPermissionAliasEnum.WAREHOUSE),
    STOCK_SEARCH(XbbRefTypeEnum.STOCK_SEARCH.getCode(), ProPermissionAliasEnum.STOCK_SEARCH),
    BOM_BILL(XbbRefTypeEnum.BOM_BILL.getCode(), ProPermissionAliasEnum.BOM_BILL),
    SIMULATED_PRODUCTION(XbbRefTypeEnum.SIMULATED_PRODUCTION.getCode(), ProPermissionAliasEnum.SIMULATED_PRODUCTION),
    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), ProPermissionAliasEnum.PRODUCTION_ORDER),


    PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(), ProPermissionAliasEnum.PRODUCT),
    PRODUCT_MANAGEMENT(XbbRefTypeEnum.PRODUCT.getCode(), ProPermissionAliasEnum.PRODUCT_MANAGEMENT),


    FUND_MANAGEMENT(XbbRefTypeEnum.FUND_MANAGEMENT.getCode(), ProPermissionAliasEnum.FUND_MANAGEMENT),
    PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(), ProPermissionAliasEnum.PAYMENT),
    PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(), ProPermissionAliasEnum.PAY_PLAN),
    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), ProPermissionAliasEnum.PAYMENT_SHEET),
    PAY_SHEET(XbbRefTypeEnum.PAY_SHEET.getCode(), ProPermissionAliasEnum.PAY_SHEET),
    INVOICE(XbbRefTypeEnum.INVOICE.getCode(), ProPermissionAliasEnum.INVOICE),
    PURCHASE_INVOICE(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(), ProPermissionAliasEnum.PURCHASE_INVOICE),

    MARKET_MANAGEMENT(XbbRefTypeEnum.MARKET_MANAGEMENT.getCode(),ProPermissionAliasEnum.MARKET_MANAGEMENT),
    MARKET_ACTIVITY(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), ProPermissionAliasEnum.MARKET_ACTIVITY),
    CLUE(XbbRefTypeEnum.CLUE.getCode(), ProPermissionAliasEnum.CLUE),

    UNKNOWN(404, ProPermissionAliasEnum.UNKNOWN),

    ;

    private Integer code;

    private ProPermissionAliasEnum proPermissionAliasEnum;


    CloudCodeAppPermissinlEnum(Integer code, ProPermissionAliasEnum proPermissionAliasEnum){
        this.code = code;
        this.proPermissionAliasEnum = proPermissionAliasEnum;
    }

    public static CloudCodeAppPermissinlEnum getByCode(Integer code) {
        for (CloudCodeAppPermissinlEnum cacheCode : values()) {
            if (Objects.equals(cacheCode.getCode(), code)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public static CloudCodeAppPermissinlEnum getByAlias(String alias) {
        for (CloudCodeAppPermissinlEnum cacheCode : values()) {
            if (Objects.equals(cacheCode.getProPermissionAliasEnum().getAlias(), alias)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
}
